﻿@section head{
    <link rel="stylesheet" href="~/css/table.css" type="text/css">
    <script type="text/javascript"
            src="~/javascript/comm/comm.js">
    </script>
}

<!DOCTYPE html>
@*<script type="text/javascript">
    function check() {
        if (document.getElementById("firstKind.ffkId").value == 0) {
            alert("请选择I级机构名称!!!");
            return false;
        }
        if (document.getElementById("secondKind.secondKindName").value == "") {
            alert("II级机构名称不能为空!!!");
            return false;
        }
        if (document.getElementById("secondKind.secondSalaryId").value == "") {
            alert("薪酬发放责任人编号不能为空!!!");
            return false;
        }
        if (document.getElementById("secondKind.secondSaleId").value == "") {
            alert("销售责任人编号不能为空!!!");
            return false;
        }
        document.forms[0].submit();
    }
    function change() {
        var se = document.getElementById("firstKindId");
        document.getElementById("firstKindName").value = se.options[se.selectedIndex].innerHTML;

    }
</script>*@
<body>
    <div id="app">
        <form action="second_kind_register_success.html" method="post" id="form">
            <input type="hidden" id="firstKindName" name="cfsk.firstKindName">
            <table width="100%">
                <tr>
                    <td>
                        <font color="black">
                            您正在做的业务是：人力资源--客户化设置--人力资源档案管理设置--II级机构设置--II级机构添加
                        </font>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <input type="button" v-on:click="Add()" value="提交" class="BUTTON_STYLE1">
                        <input type="button" value="返回" class="BUTTON_STYLE1"
                               onclick="history.back();">
                    </td>
                </tr>
            </table>


            <table width="100%" border="1" cellpadding=0 cellspacing=1
                   bordercolorlight=#848284 bordercolordark=#eeeeee
                   class="TABLE_STYLE1">
                <tr>
                    <td width="19%" class="TD_STYLE1">
                        I级机构名称
                    </td>
                    <td width="81%" class="TD_STYLE2">
                        <input hidden="hidden" id="first_kind_name" name="first_kind_name"  v-model="first_kind_name" />
                        <select name="first_kind_id" id="first_kind_id" v-model="first_kind_id">
                            <option vaule=""selected="selected">请选择I级机构名称...</option>
                            <option v-for="(item,index) in onelist" :value="item.first_kind_id">{{item.first_kind_name}}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td width="19%" class="TD_STYLE1">
                        II级机构编号
                    </td>
                    <td width="81%" class="TD_STYLE2">
                        <input type="text" class="INPUT_STYLE1" id="second_kind_id" name="second_kind_id" value=""  v-model="second_kind_id" />
                    </td>
                </tr>
                <tr>
                    <td class="TD_STYLE1">
                        II级机构名称
                    </td>
                    <td class="TD_STYLE2">
                        <input type="text" class="INPUT_STYLE1" id="second_kind_name" name="second_kind_name" value=""  v-model="second_kind_name" />
                    </td>
                </tr>
                <tr>
                    <td class="TD_STYLE1">
                        薪酬发放责任人编号（多个编号之间请用"半角逗号"加"一个空格"隔开，如", "）
                    </td>
                    <td class="TD_STYLE2">
                        <textarea rows="4" cols="" class="TEXTAREA_STYLE1" id="second_salary_id" name="second_salary_id"  v-model="second_salary_id"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="TD_STYLE1">
                        销售责任人编号（多个编号之间请用"半角逗号"加"一个空格"隔开，如", "）
                    </td>
                    <td class="TD_STYLE2">
                        <textarea rows="4" cols="" class="TEXTAREA_STYLE1" id="second_sale_id" name="second_sale_id"  v-model="second_sale_id"></textarea>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</body>
<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            onelist: [],
            first_kind_id: "",
            first_kind_name:"",
            second_kind_id: "",
            second_kind_name: "",
            second_salary_id: "",
            second_sale_id:""
        },
        methods: {
            load: function () {
                var t = this;
                $.ajax({
                    url: "/client/GetAllFId",
                    type: "Post",
                    success: function (msg) {
                        var dts = eval("("+msg+")");
                        t.onelist = dts;
                    }
                })
            },
            Add: function () {
                var first_id = $("#first_kind_id option:selected").text();
                $("#first_kind_name").val(first_id);

                var first_kind_name = $("#first_kind_id option:selected").text();
                var second_kind_id = $("#second_kind_id").val();
                var second_kind_name = $("#second_kind_name").val();
                var second_salary_id = $("#second_salary_id").val();
                var second_sale_id = $("#second_sale_id").val();

                if (first_kind_name == "") {
                    alert('请选择I级机构下拉框！！！');
                    return false;
                } else if (second_kind_id == "") {
                    alert('请输入II级机构编号！');
                    return false;
                } else if (second_kind_name == "") {
                    alert('请输入II级机构名称！！');
                    return false;
                } else if (second_salary_id == "") {
                    alert('请输入薪酬发放责任人编号！');
                    return false;
                } else if (second_sale_id == "") {
                    alert('请输入销售责任人编号！');
                    return false;
                }
                $.ajax({
                    url: "/client/second_kind_register",
                    type: "Post",
                    data: $("#form").serialize(),
                    success: function (msg) {
                        if (msg > 0) {
                            alert('新增成功!');
                            window.location.href = '/client/second_kind_register_success';
                        } else {
                            alert('新增失败!');
                        }
                    }
                })
            }
        },
        mounted: function () {
            this.load();
        }
    })
</script>
